import {
  getUserInfo
} from '../assets/js/utils'


/**
 *  获取验证码
 *  @param {phone} 必传
 */
export const getValidateCode = (phone) => {
  return new Promise((resolve, reject) => {
    $axios.post('/merchant-user/madmin/merchantUser/sendValidateCode', {
      phone
    }).then(res => {
      if (res.code == 200) {
        resolve(res)
      } else {
        reject(err)
      }
    }).catch(err => {
      reject(err)
    })
  })
}

//获取店铺详情接口
export const getStoreDetails = (params) => {
  return new Promise((resolve, reject) => {
    $axios.post('/merchant-shop/madmin/merchantShopDetails/queryShopDetails', params).then(res => {
      resolve(res)
    })
  })
}

/**
 *  获取分类列表
 *  @param {pageNum,pageSize} 分页分数，非必传
 */

export const getClassify = (params = {}) => {
  return new Promise((resolve, reject) => {
    $axios.post('/merchant-product/madmin/merchantProductCategory/listProductCategory', {
      merchantId: getUserInfo('merchantId'),
      ...params
    }).then(res => {
      resolve(res)
    })
  })
}


/**
 *  获取台位区域
 *  @param {shopId} 门店ID
 */

export const getTableArea = (params = {}) => {
  return new Promise((resolve, reject) => {
    $axios.post('/merchant-shop/madmin/merchantArea/listArea', params).then(res => {
      resolve(res)
    })
  })
}

export const getListIndustry = () => {
  return new Promise((resolve, reject) => {
    $axios.post('/merchant-shop/madmin/merchantIndustry/listIndustry', { code: "JS_IND" }).then(res => {
      resolve(res)
    })
  })
}


export const scanProductInfo = (params = {}) => {
  return new Promise((resolve, reject) => {
    $axios.get('/merchant-product/madmin/scanProduct/scanProductInfo', {
      merchantId: getUserInfo('merchantId'),
      ...params
    }).then(res => {
      resolve(res)
    })
  })
}
export const getMenu = (roleId, treeType) => {
	return new Promise((resolve, reject) => {
		$axios.post('/sel/toTreeLoad', {
		}).then(res => {
			resolve(res)
		}).catch(()=>{
    })
	})
}